import request from '@/utils/request.js';
const state = {
	categoryDataList: []
}
const mutations = {
	SET_CATEGORYDATA(state, categoryDataList){
		state.categoryDataList = categoryDataList;
	}
}
const actions = {
	// 获取分类列表
	async getCategoryList({commit}){
		const result = await request('/getCategoryData');
		console.log(result);
		commit('SET_CATEGORYDATA', result);
	}
}
const getters = {
	banner(state){
		return (state.categoryDataList[0] || []).banner || []
	},
	subCategory(state){
		return (state.categoryDataList[0] || []).second || []
	}
}

export default {
	namespaced: true,
	state,
	mutations,
	actions,
	getters
}